﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp.Demos.SimplePipeline
{
    public class HttpListenerFeatureByCustom : IHttpRequestFeatureByCustom, IHttpResponseFeatureByCustom
    {
        private readonly HttpListenerContext _context;

        public HttpListenerFeatureByCustom(HttpListenerContext context)
        {
            _context = context;
        }

        #region IHttpRequestFeatureByCustom
        Uri IHttpRequestFeatureByCustom.Url => _context.Request.Url;
        NameValueCollection IHttpRequestFeatureByCustom.Headers => _context.Request.Headers;
        Stream IHttpRequestFeatureByCustom.Body => _context.Request.InputStream;
        #endregion

        #region IHttpResponseFeatureByCustom
        NameValueCollection IHttpResponseFeatureByCustom.Headers => _context.Response.Headers;
        Stream IHttpResponseFeatureByCustom.Body => _context.Response.OutputStream;
        int IHttpResponseFeatureByCustom.StatusCode
        {
            get => _context.Response.StatusCode;
            set => _context.Response.StatusCode = value;
        }
        #endregion
    }
}
